how capacitor works